// component/index/brand/brand.js
const app = getApp();
Component({
	/**
	 * 组件的属性列表
	 */
	properties: {
        "brand":{type:Array}
	},

	/**
	 * 组件的初始数据
	 */
	data: {
	},

	lifetimes:{
	    attached() {
			let extConfig = wx.getExtConfigSync? wx.getExtConfigSync(): {};
			if(extConfig.hidecateory != null && extConfig.hidecateory == 1) {
				this.setData({
					hidecategory: true
				});
			} else {
				this.setData({
					hidecategory: false
				});
			}
		}
	},

	/**
	 * 组件的方法列表
	 */
	methods: {
		brandsku: function (e) {
			let item = e.currentTarget.dataset.item;
			console.log(item)
			switch (item[`link_type`]){
				case 0:
					let id = item[`category_id`];
					// wx.setStorage({key:"category_id", id})旧
					wx.setStorageSync('category_id', id)
					let extConfig = wx.getExtConfigSync? wx.getExtConfigSync(): {} ;
					if(extConfig.category = null || extConfig.category == 0) {
						wx.navigateTo({
							url: '/pages/index/categorysku/categorysku',
						})
					} else {
						wx.navigateTo({
							url: '/pages/index/newcategory/newcategory?id=' + id,
						})
					}
					break;
				case 1:
					wx.navigateTo({
						url:'/pages/index/brandsku/brandsku?id=' + item['topic_id']
					})
					break;
				case 2:
					break;
			}
		},
		changold(){
			let extConfig = wx.getExtConfigSync? wx.getExtConfigSync(): {} ;
			if(extConfig.category = null || extConfig.category == 0) {
				wx.navigateTo({
					url: '/pages/index/categorysku/categorysku',
				})
			} else {
				wx.navigateTo({
					url: '/pages/index/newcategory/newcategory',
				})
			}
		},
	}
})
